﻿using System;
using System.Windows.Data;
using System.Collections.Generic;
using System.ServiceModel.Syndication;
using System.Linq;
using ZFCNew.Code;

namespace ZFCNew.Converters
{
    public class LinkToPostConverter : IValueConverter
    {
        private const string TweetLink = "http://twitter.com/{0}/status/{1}";
        private const string FacebookLink = "http://www.facebook.com/profile.php?id={0}&v=wall";

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is TwitterSearchResult)
            {
                var mValue = (TwitterSearchResult) value;
                return string.Format(TweetLink, mValue.FromUser, mValue.Id);
            }
            if (value is FbSearchResult)
            {
                var mValue = (FbSearchResult)value;
                return string.Format(FacebookLink,  mValue.From.ID);
            }
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
